#!/usr/bin/python

import examples.basegame
import ai.steer.engine as steer
import euclid
import random
import game

class HiderBoid( examples.basegame.DemoBoid ):
    def __init__(self, target, window, pos, mass, maxspeed, maxforce, maxturnrate):
        super( HiderBoid, self ).__init__( window, pos, mass, 70, maxforce, maxturnrate )
        self.hide = steer.Hide( target, 1, 2 )
        self.steer.add( self.hide )
        self.steer.add( steer.ObstacleAvoidance( 1, 4 ) )

        self.colour = ( 0, 255, 0 )

class BadBoid( examples.basegame.DemoBoid ):
    def __init__(self, window, pos, mass, maxspeed, maxforce, maxturnrate):
        super( BadBoid, self ).__init__( window, pos, mass, 20, maxforce, maxturnrate )

        self.wander = steer.Wander( 50, 50, 10, 2, 1 )
        self.steer.add( self.wander )
        self.steer.add( steer.ObstacleAvoidance( 1, 2 ) )

        self.colour = ( 255, 0, 0 )

class HideDemo( examples.basegame.BaseGame ):
    def setup(self):
        super( HideDemo, self ).setup()

        p1 = euclid.Point3(
            int(random.uniform( 0, self.window.width )),
            int(random.uniform( 0, self.window.height )),
            0 )

        p2 = euclid.Point3(
            int(random.uniform( 0, self.window.width )),
            int(random.uniform( 0, self.window.height )),
            0 )

        p3 = euclid.Point3(
            int(random.uniform( 0, self.window.width )),
            int(random.uniform( 0, self.window.height )),
            0 )

        self.bad = BadBoid( self.window, p1, 10, 50, 50, 50 )
        self.hide1 = HiderBoid( self.bad, self.window, p2, 2, 50, 50, 50 )
        self.hide2 = HiderBoid( self.bad, self.window, p3, 2, 50, 50, 50 )

        for i in range(10):
            p = euclid.Point3(
            int(random.uniform( 0, self.window.width )),
            int(random.uniform( 0, self.window.height )),
            0 )
            r = random.uniform( 10, 30 )
            game.entity.Obstacle( r, self.window, p )
